
<title><?=$v['title']?></title>
<script src="js/ui/PopWindow.js" type="text/javascript"></script>
<script src="js/Calendar.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<link rel="stylesheet" type="text/css" href="css/page.css"/>
<link rel="stylesheet" type="text/css" href="css/sell_product.css"/>
<div class="content">
	<h3 class="mc_title">
		<span class="mctit_1"><span class="mctit_2"><?=$v['title']?></span></span>
    </h3>
	<div class="mcsear_box">
		<form action="<?=$_SERVER['PHP_SELF']?>" class="report">
			<input type="hidden" name="act" id="act" />
			<input type="hidden" name="atype" value="<?=$atype?>" />
			<input type="hidden" name="currentPage" value="1"/>
			<input type="hidden" name="status" id="status" value="<?=$_REQUEST['status']?>"/>
			<ul class="search">
				<li>
					<span>
						<label>查询条件：</label>
						<select name="tjs" class="sType">
							<option value="">--请选择--</option>
							<option <?=$_REQUEST['tjs']=="0"?"selected":""?> value="0">订单号</option>
							<option <?=$_REQUEST['tjs']=="1"?"selected":""?> value="1">产品名称</option>
							<option <?=$_REQUEST['tjs']=="2"?"selected":""?> value="2">取票人姓名</option>
							<option <?=$_REQUEST['tjs']=="3"?"selected":""?> value="3">取票人手机</option>
							<?if($v['from']!="buy"){?>
							<option <?=$_REQUEST['tjs']=="4"?"selected":""?> value="4">分销商名称</option>
							<?}?>
							<?if($v['from']=="buy"||$_SESSION['dtype']==9){?>
							<option <?=$_REQUEST['tjs']=="5"?"selected":""?> value="5">供应商名称</option>
							<?}?>
							<option <?=$_REQUEST['tjs']=="6"?"selected":""?> value="6">远端订单号</option>
						</select>
						<? if( !$hideList && ($_REQUEST['tjs']==5 || $_REQUEST['tjs']==4)):?>
						<select style="width:180px;height:23px;border: 1px solid #2A98DA;box-shadow: 1px 1px 1px #B0DFFD;" class="distors" name="txt">
							<? foreach($DistorsNames as $k):?>
							<?
								$selected='';
								if ($_REQUEST['txt']==substr($k,2))
									$selected='selected="selected"';//
							?>
							<option value="<?=substr($k,2)?>" <?=$selected?>><?=$k?></option>
							<?endforeach;?>
						</select>
						<?endif;?>
						<?
						$style='';
						$names='name="txt"';
						if(!$hideList && ($_REQUEST['tjs']==5 || $_REQUEST['tjs']==4)){
							$style='style="display:none;"';
							$names='';
						}
						?>
						<input type="text" <?=$names?>  class="inputText svalue" value="<?=$_REQUEST['txt']?>" <?=$style?>/>
					</span>
					<span>
						<label>支付方式：</label>
						<input type="checkbox" name="payinfo[]" <?=(in_array(0,$_REQUEST['payinfo']))?"checked":""?> value="0" />
						<label for="mck1">账户余额</label>
						<input type="checkbox" name="payinfo[]" <?=(in_array(1,$_REQUEST['payinfo']))?"checked":""?> value="1"/>
						<label for="mck2">支付宝</label>
						<input type="checkbox" name="payinfo[]" <?=(in_array(2,$_REQUEST['payinfo']))?"checked":""?> value="2"/>
						<label for="mck3">授信支付</label>
					</span>
					<span>
						<input type="submit" class="sbtn" value=""/>

					</span>
				</li>
				<li>
					<span>
						<label>订单时间：</label>
						<select class="" name="xtimes">
							<option <?=$_REQUEST['xtimes']=="1"?"selected":""?> value="1">--下单时间-</option>
							<option <?=$_REQUEST['xtimes']=="2"?"selected":""?> value="2">--预计游玩-</option>
							<option <?=$_REQUEST['xtimes']=="3"?"selected":""?> value="3">--完成时间-</option>	
						</select>
						<input type="text" name="begintime" readOnly onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)"  class="inputText time" value="<?=$_REQUEST['begintime']?>"/>
						<label>至</label>
						<input type="text" name="endtime" readOnly onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" class="inputText time" value="<?=$_REQUEST['endtime']?>"/>
					</span>
					<span>
						<label>搜索排序：</label>
						<select name="orderby">
							<option value="">--请选择--</option>
							<option <?=$_REQUEST['orderby']=="1"?"selected":""?> value="1" >-下单时间-</option>
							<option <?=$_REQUEST['orderby']=="2"?"selected":""?> value="2" >-游玩时间-</option>
							<option <?=$_REQUEST['orderby']=="3"?"selected":""?> value="3" >-验证时间-</option>
							<option <?=$_REQUEST['orderby']=="5"?"selected":""?> value="5" >-产品标题-</option>
						</select>
						<select name="sort">
							<option <?=$_REQUEST['sort']=="1"?"selected":""?> value="1" >-降序-</option>
							<option <?=$_REQUEST['sort']=="0"?"selected":""?> value="0" >-升序-</option>
						</select>
					</span>
					<input type="button" id="excel" class="btn" value="导 出"/>
					<span>
					<!--
					<select id="oneCount" name="LoadEc">

					</select>
					-->
					</span>
					<style type="text/css">
					.btn{padding: 4px 15px;background: url("images/mc_title.png") no-repeat right top;color: #fff;border: none;cursor: pointer;}
					#oneCount{height:26px;}
					</style>
				</li>
			</ul>
		</form>
		<ul class="mcul">
			<li class="<?=!isset($_REQUEST['status'])||$_REQUEST['status']===""?"acrt":""?>"><a href="#" status="" >所有订单</a></li>
			<li class="<?=$_REQUEST['status']=="1"?"acrt":""?>"><a href="#" status="1" >已使用</a></li>
			<li class="<?=$_REQUEST['status']=="0"?"acrt":""?>"><a href="#" status="0" >未使用</a></li>
			<li class="<?=$_REQUEST['status']=="2"?"acrt":""?>"><a href="#" status="2" >已过期</a></li>
			<li class="<?=$_REQUEST['status']=="3"?"acrt":""?>"><a href="#" status="3" >已取消</a></li>
		</ul>
		
	</div>
   <div class="section popupwz">
		<table class="mclist_tab">
			<tfoot class="counts">
				<td colspan="11" class="surtd">
				<span style="float:right; margin-right:25px; line-height:30px;">
				<h4>
					统计结果：
					<span>订单数：<em class="green"><?=$orderCount?></em>单</span>
					<span>数 量：<em class="pink"><?=$ticketCount?></em></span>
					<span>总金额：<em class="red"><?=$allMoney?></em>元</span>
				</h4>
				</span>	
				</td>
			</tfoot>
			<thead>
				<tr class="thead1">
				<tr class="thead2">
					<td colspan="10">
						<div id="topPage">
						<?page($count,$currentPage,$pageSize,$order,$by);?>
						</div>
					</td>
				</tr>
				<div class="section popupwz">
				<table class="orders" id="orders" >
			<thead> 
			<th width="52" class="tl">订单号</th>
			<th width="137">产品信息</th>
            <th width="43">单价</th>
            <th colspan="3">取票人信息</th>
			<?if($showDtr){?>
			<?
				if($v['from']=='buy'){// 已买到
					echo '<th width="155">供应商</th>';
				}else{// 已卖出
					echo '<th width="155">分销商</th>';
				}
			?>
			
			<?}?>
            <th width="63">支付方式</th>
			<th width="62">订单状态</th>
			<th width="100">总金额</th>
			<th width="109">操作</th>
			</thead>
			<? //print_r($r);
			foreach($r as $row):
				$childNum = count($row['childOrder']);
			?>
        	<tr>
				<td rowspan="<?=$childNum + 2?>" class="borsoli">
					<?if((string)$row['mainOrder']->UUp_type=='F'):?>
					<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>&pack=1" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
					<?else:?>
						<?if(isMainOrder($row['mainOrder']->UUconcat_id)):?>
						<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>&pack=1" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
						<?else:?>
						<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
						<?endif;?>
					<?endif;?>
				</td>
				<td colspan="10" class="txtleft">
					<?if((string)$row['mainOrder']->UUremotenum){?>
					<span>远端订单号：<?=(string)$row['mainOrder']->UUremotenum?></span></br>
					<?}?>
					<span>下单时间：<?=(string)$row['mainOrder']->UUordertime?></span>
					<span>预计游玩:<?=(string)$row['mainOrder']->UUbegintime?></span>
					<span>验证时间：<?=(string)$row['mainOrder']->UUdtime!="0000-00-00 00:00:00"?(string)$row['mainOrder']->UUdtime:"未验证"?></span>
				</td>
			</tr>
			<tr>
				<td class="txtleft">
					<?=(string)$row['mainOrder']->UUltitle?></br>【<?=(string)$row['mainOrder']->UUttitle?>】<span style="color:#FC6602; font-size:14px;text-align:center">
						*<?=(string)$row['mainOrder']->UUtnum?>张
					</span>
				</td>
				<td>

					<i class="money">￥</i><?=(string)$row['mainOrder']->UUtprice/100?>
				</td>
				<td rowspan="<?=$childNum + 1;?>" colspan="3">
					<span><?=(string)$row['mainOrder']->UUordername?></span></br>
					<span><?=(string)$row['mainOrder']->UUordertel;//.'|'.$row['mainOrder']->UUaids;?></span>
				</td>
				<?if($showDtr){?>
				<td rowspan="<?=$childNum + 1;?>">

					<?
						if($v['from']=='buy'){// 已买到
							echo $anames[(int)$row['mainOrder']->UUsellid]?
							$anames[(int)$row['mainOrder']->UUsellid]:(string)$row['mainOrder']->UUdname;
						}else{// 已卖出
							echo $fnames[(int)$row['mainOrder']->UUbuyid]?
							$fnames[(int)$row['mainOrder']->UUbuyid]:(string)$row['mainOrder']->UUdname;
						}
					?>
				</td>
				<?}?>
				
				<td rowspan="<?=$childNum + 1;?>">
					<?=OrderRecord::$paymodeT[(string)$row['mainOrder']->UUpmode]?>
					<?if($row['mainOrder']->UUordermode!=0){?>
						</br><em class="fuchsia">(游客预订)</em>
					<?}?>
				</td>
				<td rowspan="<?=$childNum + 1;?>">
					<span rowspan="<?=$row['totalOrder']?>">
					<?=$uuStatus[(string)$row['mainOrder']->UUstatus]?></br>
					<?if($row['mainOrder']->UUstatus==0){?>
					<?=OrderRecord::$paystatusT[(string)$row['mainOrder']->UUpaystatus]?>
					<?}?>
					</span>
				</td>
				<td rowspan="<?=$childNum + 1;?>" class="rigsoli">
					
					<?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
					合计：
					<span style=" color:#f60; font-size:14px; font-weight:bold; line-height:21px;">
						<span class="money"><i class="money">￥</i><?=(string)$row['totalPrice']/100?></span>
					</span>
					<?else:?>
					<?
						$total = 0;
						foreach($row['childOrder'] as $cr){
							$total = $total + (string)$cr['totalPrice']/100 ;
						}
						$total += (string)$row['totalPrice']/100;
					?>
					合计：
					<span style=" color:#f60; font-size:14px; font-weight:bold; line-height:21px;">
						<span class="money"><i class="money">￥</i><?=$total;?></span>
					</span>
					<?endif;?>
				</td>
				<td rowspan="<?=$childNum + 1;?>">
				<span class="vidhid show">
                   <?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
						<?if((string)$row['mainOrder']->UUp_type=='F'):?>
						<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>&pack=1">查看</a></br>
						</span>
						<?else:?>
						<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>">查看</a></br>
						</span>
						<?endif;?>
                  <span class="vidhid ">
                     <?if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderCancel")){?>

						<a act="cancel" class="orderHandle" href="call/handle.php?from=order_cancel&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">取消</a>
						</br>

						<?}?>onclick="restoreOrder(261223,1,2,779);">恢复</a>                    </span>
                  <span class="vidhid ">
                     <?if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderAlipay")){?>
						<a target="_blank" href="alipayOrder.html?ordernum=<?=(string)$row['mainOrder']->UUordernum?>">支付</a></br>
						<?}?></span>
                  <span class="vidhid show">
					<?if((string)$row['mainOrder']->UUifpack!=2):// 不是子票的才显示?>
                     <?if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderCancel")){?>
						<a act="cancel" class="orderHandle" href="call/handle.php?from=order_cancel&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">取消</a></br>
						<?}?> </span>
                  <span class="vidhid show">
                     <?if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderAlter")){?>
						<a  class="alter" href="call/handle.php?from=orderAlterHtml&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">修改</a></br>
						<?}?>
				</span>
                  <span class="vidhid show">
                      <?if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderResend")){?>
						<a act="cancel" class="resend" href="call/handle.php?from=order_resend&&ordernum=<?=(string)$row['mainOrder']->UUordernum?>">重发</a></br>
						<?}?></span>
				   <?endif;// 不是子票的才显示?>
                  <span class="vidhid show">
					<?endif;?>
						<?if(isMainOrder($row['mainOrder']->UUconcat_id)):?>
							<span>复票订单</br><a href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>&pack=1
" target="_blank">查看详细</a></span>
						<?endif;?>
						<?if($_SESSION['dtype']==2 && in_array($_SESSION['account'],$arr_salerid)):?>
							<span><?=$row['mainOrder']->UUcode?></span>
						<?endif;?>
				</td>
			</tr>
			<?foreach($row['childOrder'] as $cr):?>
			<tr>
				<td class="txtleft">
					<?=(string)$cr['mainOrder']->UUltitle?></br>【<?=(string)$cr['mainOrder']->UUttitle?>】<span style="color:#FC6602; font-size:14px;text-align:center">
						*<?=(string)$cr['mainOrder']->UUtnum?>张
					</span>
				</td>
				<td>
					<i class="money">￥</i><?=(string)$cr['mainOrder']->UUtprice/100?>
				</td>
			</tr>
			<?endforeach;?>
			<?endforeach;?>
			<tfoot class="counts">
				<td colspan="11" class="surtd">
				<span style="float:right; margin-right:25px; line-height:30px;">
				<h4>
					统计结果：
					<span>订单数：<em class="green"><?=$orderCount?></em>单</span>
					<span>数 量：<em class="pink"><?=$ticketCount?></em></span>
					<span>总金额：<em class="red"><?=$allMoney?></em>元</span>
				</h4>
				</span>	
				</td>
			</tfoot>
	</table>
	
	
</div>
			</thead>
			<?foreach($r as $key=>$row){
			   $arr_salerid=array(501610,501612);
			?>
			
			<!--
			/*
			<?foreach($row['childOrder'] as $c_order){?>
				<tr class="tbody2">
					<td><?=$c_order->UUordernum?></td>
					<td class="title"><?=(string)$c_order->UUltitle?><?=(string)$c_order->UUttitle?></td>
					<td class="tprice"><i class="money">￥</i><?=(string)$c_order->UUtprice/100?></td>
					<td class="tnum"><?=(string)$c_order->UUtnum?></td>
				</tr>
			<?}?>
			*/
			-->
			</tbody>
			<?}?>
			<!-- <tfoot class="tfoot1">
				<td colspan="10">
					<div class="">
					</div>
					<!-- <label for="chkall2"><input type="checkbox" class="mchck" id="chkall2" />全选</label>
					<input type="button" class="thedbtn" value="批量验证订单" /> 
				</td>
			</tfoot> -->
		</table>	
		<?page($count,$currentPage,$pageSize,$order,$by);?>
   </div>
</div>
<script>
	var popWindow=new PopWindow();
	$(".alter").click(function(){
		$.ajax({
			"url":$(this).attr("href"),
			"success":function(data){
				popWindow.open(data);
				$("form.changetnum input.cancel").click(function(){
					popWindow.close();
				});
				$("form.changetnum").submit(function(){
					popWindow.close();
					var str=$(this).serialize();
					$.ajax({
						"url":"call/handle.php?from=order_alter&"+str,
						"dataType":"json",
						"success":function(data){
							if(data.outcome==1){
								alert(data.msg);
								window.location=window.location.href;
							}else{
								alert(data.msg);
							}
						}
					});
					return false;
				});
				
			}
		})
		return false;
	});
	$(".orderHandle").click(function(){
		if($(this).attr("act")=="cancel"){
			if(!confirm("确定要取消该订单？")) return false;
		}
		$.ajax({
			"url":$(this).attr("href"),
			"dataType":"json",
			"success":function(data){
				if(data.outcome==1){
					alert("取消成功");
					window.location=window.location.href;
					/*$(this).parent().prev().prev().html('<em class="red">已取消</em>');
					var textT=$(this).find("a").first().text();
					$(this).parent().html(textT);*/
				}else{
					alert("取消失败"+data.msg);
				}
			}
		})
		return false;
	});
	$(".resend").click(function(){
		if($(this).attr("act")=="cancel"){
			if(!confirm("确定要重发短信？")) return false;
		}
		$.ajax({
			"url":$(this).attr("href"),
			"dataType":"json",
			"success":function(data){
				if(data.outcome==1){
					alert("重发成功");
				}else{
					alert("重发失败:"+data.msg);
				}
			}
		})
		return false;
	});
	$(".mcul li a").click(function(){
		$("#status").val($(this).attr("status"));
		$(".sbtn").click();
		return false;
	})
	
	$("#excel").click(function(){
		
		$("#act").val("Export");
		$("form.report").submit();
		$("#act").val("");
	});
	
	// 按供应商查询获取供应商列表
	$(".sType").change(function(){
		if($(this).val()!=5 && $(this).val()!=4){
			$(".svalue").show().attr("name","txt");
			if($(".distors").length>0){
				$(".distors").hide().removeAttr("name");
			}
			return 0;
		}
			
		
		//如果有列表，不重复获取
		if($(".distors").length>0){
			$(".svalue").hide().removeAttr("name");
			$(".distors").show().attr("name","txt");
			return 0;
		}
		_parent = $(this).parent();
		$.ajax({
			uri:window.location.href,
			beforeSend:function (XMLHttpRequest) {
				XMLHttpRequest.setRequestHeader("request_type","getDistors");
			},
			success: function(data){
				data = JSON.parse(data);
				if(data.s=='success'){
					var selectTxt ='<select style="width:180px;height:23px;border: 1px solid #2A98DA;box-shadow: 1px 1px 1px #B0DFFD;" class="distors" name="txt">';
					selectTxt+='<option value="">--选择--</option>';
					for(var i in data.d){
						selectTxt+='<option value="'+data.d[i].substr(2)+'">'+data.d[i]+'</option>';
					}
					selectTxt+='</select>';
					$(".svalue").hide().removeAttr("name");
					_parent.append(selectTxt);
				}
			}
		});
	});
</script>